<?php
namespace jy_wxshifu;
defined('BY_JYA') or exit('error');
/*
*/
class notice extends \plugin{
	public function gettpl_data($orderid,$type=0){//type=0表单订单，type=1
		return false;
	}
	/*
		师傅新任务通知
	*/
	public function notice_orderget($order_id,$url=''){
		//新服务任务通知给师傅
		$order=pdo_get('jy_wxshifu_order',array('id'=>$order_id,'uniacid'=>$_SESSION['uniacid']));
		$mid=pdo_getcolumn('jy_wxshifu_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$order['shifuid']),'mid');
		$orderinfo=$this->model('model')->getorder($order,1);
		$template_id=cfc('account')->get_tpl_template_id('OPENTM416739152','新服务任务通知');
		if($_SESSION['wxapp_id']){
			$wxapptemplate_id=cfc('wxapp_api')->get_tpl_template_id('17468',[1,2,3,7],'orderget','新服务任务通知','jy_wxshifu');
		}
		$message=array(
			'first'=>array('value'=>'新服务任务通知',"color" => "#4a5077"),
			'keyword1'=>array('value'=>$orderinfo['ordersn'],"color" => "#4a5077"),
			'keyword2'=>array('value'=>date('Y/m/d H:i:s',$order['createtime']),"color" => "#4a5077"),
			'keyword3'=>array('value'=>$orderinfo['goods'][0]['goods_title'],"color" => "#4a5077"),
			'keyword4'=>array('value'=>$orderinfo['addresstext'],"color" => "#4a5077"),
			'remark'=>array('value'=>'您有新的服务订单！请及时处理！点击“详情”查看订单信息。',"color" => "#4a5077"),
		);
		$wxappmsg=array(
			array('value'=>$orderinfo['ordersn']),
			array('value'=>date('Y/m/d H:i:s',$orderinfo['createtime'])),
			array('value'=>$orderinfo['goods'][0]['goods_title']),
			array('value'=>$orderinfo['addresstext']),
		);
		if(!$url){
			$url=custom_url('jy_wxshifu/worker_order/',true);	
		}
		if(method_exists(cfc('account'),'sendtwoNotice')){
			cfc('account')->sendtwoNotice($mid,$template_id,$message,$url,'orderget','jy_wxshifu',$order_id);
		}
		if($_SESSION['wxapp_id']){
			$url='/jy_wxshifu/worker_order/detail/index?id='.$order['id'];
			$template_id=cfc('wxapp_api')->checktplNotice($mid,$wxapptemplate_id,$wxappmsg,$url,'orderget','jy_wxshifu',$order_id);
		}
	}
	public function notice_check_apply($member,$url=''){
		//审核通过
		$member=$this->get('member',array('id'=>$member['id'],'uniacid'=>$_SESSION['uniacid']));
		$template_id=cfc('account')->get_tpl_template_id('OPENTM408250107','申请成功通知');
		$message=array(
			'first'=>array('value'=>'申请成为师傅，审核通过！',"color" => "#4a5077"),
			'keyword1'=>array('value'=>$member['title'],"color" => "#4a5077"),
			'keyword2'=>array('value'=>$member['mobile'],"color" => "#4a5077"),
			'remark'=>array('value'=>'感谢你的使用。',"color" => "#4a5077"),
		);
		if(!$url){
			$url=custom_url('jy_wxshifu/index/',true);	
		}
		if(method_exists(cfc('account'),'sendtwoNotice')){
			cfc('account')->sendtwoNotice($member['mid'],$template_id,$message,$url,'check_apply','jy_wxshifu',$order_id);
		}
	}
}